home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / byte0287.arc / LISTING2 < prev    next >
Text File  |  1980-01-01  |  1KB  |  40 lines

  1. 10 OPEN "I",#1,"DATA"
  2. 20 INPUT#1,N    :REM Get data count.
  3. 30 DIM A(N)
  4. 40 FOR I=0 TO N    :REM Get original data set.
  5. 50 INPUT#1,A(I)
  6. 60 NEXT I
  7. 70 CLOSE 
  8. 80 INPUT "Enter desired accuracy ";E
  9. 90 FOR L=2 TO INT(N/2-.5)
  10. 100 W=3.141593/L
  11. 110 FOR I=1 TO N    :REM Reconstruct missing values.
  12. 120 IF I MOD L=0 THEN 190 :REM Branch at sampled values.
  13. 130 G=0
  14. 140 FOR J=0 TO N STEP L :REM The Nyquist sum.
  15. 150 M=W*(I-J)
  16. 160 G=G+A(J)*SIN(M)/M
  17. 170 NEXT J
  18. 180 IF ABS(G-A(I))>E THEN 210 :REM Sum done; test accuracy.
  19. 190 NEXT I    :REM If ok, reconstruct next value.
  20. 200 NEXT L    :REM Increment sampling interval.
  21. 210 L=L-1    :REM Highest successful sampling interval.
  22. 220 IF L>1 THEN 260    :REM L=1 means no compression possible.
  23. 230 PRINT "For an accuracy of +/-";E;"all of this data
  24.     must be kept."
  25. 240 PRINT "No compressed data file (CDATA) will be generated."
  26. 250 END    :REM Exit.
  27. 260 OPEN "o",#1,"CDATA"    :REM Create compressed data file.
  28. 270 PRINT#1,N,L    :REM Write data count, sampling interval.
  29. 280 FOR J=0 TO N STEP L    :REM Write compressed data set.
  30. 290 PRINT#1,A(J)
  31. 300 NEXT J
  32. 310 CLOSE
  33. 320 L$="th"
  34. 330 IF L=2 THEN L$="nd"    :REM Tell what you did.
  35. 340 IF L=3 THEN L$="rd"
  36. 350 PRINT "Every ";L;L$;" data value has been kept in the
  37.     compressed data file (CDATA)."
  38. 360 PRINT "The original data set can be reconstructed to
  39.     an accuracy of +/-";E
  40.